Conversation
app/src/main/java/co/stonephone/stonecamera/plugins/Portrait.kt
Outdated
Show resolved
Hide resolved
| } | ||
| } | ||
|
|
||
| fun Bitmap.saveImage(context: Context): Uri? { |
There was a problem hiding this comment.
Long term will just overwrite the saved image, but for now i wanna compare
app/src/main/java/co/stonephone/stonecamera/utils/ImageSegmenterHelper.kt
Outdated
Show resolved
Hide resolved
|
|
||
| class ImageSegmenterHelper( | ||
| var currentDelegate: Int = DELEGATE_CPU, | ||
| var runningMode: RunningMode = RunningMode.IMAGE, |
There was a problem hiding this comment.
Can set it to process on a live stream instead of images. I wonder if this will be preferable, performance wise, for the live view & how that would tie into the current plugin model?
- Old approach blurred the whole image & then applied the mask which is significantly more computationally expensive - Also fixing some lint errors
|
Newly optimised blurring algo takes roughly 700ms on pixel 6a with a large radius of 25 (not including segmentation). Defo further optimisations to be had. Will focus next on shoving it on a background thread & improving the smoothness of the blur |
Also not 100% happy with the visuals of the blur, but can polish this later after getting the images to save in the correct orientation :D |
- Remove some redundant code - General refactoring for readability
| stoneCameraViewModel: StoneCameraViewModel, | ||
| outputFileResults: ImageCapture.OutputFileResults | ||
| ) { | ||
| val portraitModeSetting = stoneCameraViewModel.getSetting<String>("portraitMode") ?: "OFF" |
There was a problem hiding this comment.
Do you think we should do this on a "mode" basis?
E.g. extend the Photo Mode plugin? Then there will be a mode option like most other camera apps?
There was a problem hiding this comment.
Yeah I think this would be a good idea. Will make that change
| private fun getOriginalImageRotation(contentResolver: ContentResolver, imageUri: Uri): Int { | ||
| val exifInputStream = contentResolver.openInputStream(imageUri) | ||
| val exif = ExifInterface(exifInputStream!!) | ||
| val rotation = when (exif.getAttributeInt( |
There was a problem hiding this comment.
Should this be more global for all modes? Perhaps I'm mis-understanding
There was a problem hiding this comment.
The image was being spat out sideways after blurring for some reason. No objection to making it more global
| ) | ||
| } | ||
|
|
||
| // Stolen from https://stackoverflow.com/questions/21418892/understanding-super-fast-blur-algorithm?fbclid=IwZXh0bgNhZW0CMTEAAR1w91ucNtw4nU-Z8Z9RyMYFVUHWxfgt7ivsE7foTkwR2wmdx2losQqQ0sk_aem_Zrf_8344PRxW6SFzutkE7g |
There was a problem hiding this comment.
Also, isn't there a way we can shift this onto a shader?
There was a problem hiding this comment.
Not aware of shaders. will take a look
| import com.google.mediapipe.tasks.vision.imagesegmenter.ImageSegmenterResult | ||
|
|
||
| class ImageSegmenterHelper( | ||
| var currentDelegate: Int = DELEGATE_CPU, |
There was a problem hiding this comment.
Can we make sure we use GPU where possible?
There was a problem hiding this comment.
I was having trouble w/ gpu but yes, I agree. Will work on making that happen
| } | ||
| } | ||
|
|
||
| when(currentModel) { |
There was a problem hiding this comment.
Are all the models included in the build at this stage? How do we strip out the ones we're not using?
There was a problem hiding this comment.
They are not, have made changes to remove references to other models
Portrait mode with MediaPipe.